import 'package:bike_ride/generated/l10n.dart';

class UserInfoM {
  UserInfoM({
    this.baseInfo,
    this.walletInfo,
  });

  UserInfoM.fromJson(dynamic json) {
    baseInfo =
        json['base_info'] != null ? BaseInfo.fromJson(json['base_info']) : null;
    walletInfo = json['wallet_info'] != null
        ? WalletInfo.fromJson(json['wallet_info'])
        : null;
  }

  BaseInfo? baseInfo;
  WalletInfo? walletInfo;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    if (baseInfo != null) {
      map['base_info'] = baseInfo!.toJson();
    }
    if (walletInfo != null) {
      map['wallet_info'] = walletInfo!.toJson();
    }
    return map;
  }
}

class WalletInfo {
  WalletInfo({
    this.deposit,
    this.depositamout,
    this.balance,
    this.ridingCardNum,
    this.couponNum,
    this.givebalance,
  });

  WalletInfo.fromJson(dynamic json) {
    deposit = json['deposit'];
    depositamout = json['depositamout'];
    balance = json['balance'];
    ridingCardNum = json['riding_card_num'];
    couponNum = json['coupon_num'];
    givebalance = json['givebalance'];
  }

  num? deposit;
  num? depositamout;
  num? balance;
  num? ridingCardNum;
  num? couponNum;
  num? givebalance;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['deposit'] = deposit;
    map['depositamout'] = depositamout;
    map['balance'] = balance;
    map['riding_card_num'] = ridingCardNum;
    map['coupon_num'] = couponNum;
    map['givebalance'] = givebalance;
    return map;
  }
}

class BaseInfo {
  BaseInfo({
    this.userId,
    this.avatar,
    this.nickname,
    this.mobile,
    this.mobileFull,
    this.age,
    this.realNameStatus,
    this.realName,
    this.realNameFull,
    this.userIdno,
    this.userIdnoFull,
    this.wxOpenId,
    this.aliOpenId,
    this.areaCode,
    this.isAuthPhone,
    this.notify,
    this.notifyId,
    this.notifyStatus,
    this.studentStatus,
    this.deleteFlag,
    this.stateFlag,
    this.brandCode,
    this.state,
  });

  BaseInfo.fromJson(dynamic json) {
    userId = json['user_id'];
    avatar = json['avatar'];
    nickname = json['nickname'];
    mobile = json['mobile'];
    if(nickname == null || nickname!.isEmpty){
      nickname = mobile??S.current.defaultName;
    }
    mobileFull = json['mobile_full'];
    age = json['age'];
    realNameStatus = json['real_name_status'];
    realName = json['real_name'];
    realNameFull = json['real_name_full'];
    userIdno = json['user_idno'];
    userIdnoFull = json['user_idno_full'];
    wxOpenId = json['wx_open_id'];
    aliOpenId = json['ali_open_id'];
    areaCode = json['area_code'];
    isAuthPhone = json['is_auth_phone'];
    notify = json['notify'];
    notifyId = json['notify_id'];
    notifyStatus = json['notify_status'];
    studentStatus = json['student_status'];
    deleteFlag = json['delete_flag'];
    stateFlag = json['state_flag'];
    brandCode = json['brand_code'];
    state = json['state'];
  }

  String? userId;
  String? avatar;
  String? nickname;
  String? mobile;
  String? mobileFull;
  int? age;
  int? realNameStatus;
  String? realName;
  String? realNameFull;
  String? userIdno;
  String? userIdnoFull;
  String? wxOpenId;
  String? aliOpenId;
  String? areaCode;
  int? isAuthPhone;
  int? notify;
  int? notifyId;
  int? notifyStatus;
  int? studentStatus;
  int? deleteFlag;
  int? stateFlag;
  String? brandCode;
  int? state;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['user_id'] = userId;
    map['avatar'] = avatar;
    map['nickname'] = nickname;
    map['mobile'] = mobile;
    map['mobile_full'] = mobileFull;
    map['age'] = age;
    map['real_name_status'] = realNameStatus;
    map['real_name'] = realName;
    map['real_name_full'] = realNameFull;
    map['user_idno'] = userIdno;
    map['user_idno_full'] = userIdnoFull;
    map['wx_open_id'] = wxOpenId;
    map['ali_open_id'] = aliOpenId;
    map['area_code'] = areaCode;
    map['is_auth_phone'] = isAuthPhone;
    map['notify'] = notify;
    map['notify_id'] = notifyId;
    map['notify_status'] = notifyStatus;
    map['student_status'] = studentStatus;
    map['delete_flag'] = deleteFlag;
    map['state_flag'] = stateFlag;
    map['brand_code'] = brandCode;
    map['state'] = state;
    return map;
  }
}
